From 9fd634cc0ec69f7a3fa7416365d4a4c550356034 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Thu, 24 Apr 2025 09:30:58 +0200 Subject: [PATCH] fix: Revert "stop using QFile api to delete a single local file" This reverts commit 58d28ab3306a5cd36d990678416375386d9a0db9. Signed-off-by: Matthieu Gallien --- src/common/filesystembase.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp index c6dcb49d1..441746aae 100644 --- a/src/common/filesystembase.cpp +++ b/src/common/filesystembase.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -541,34 +540,14 @@ bool FileSystem::remove(const QString &fileName, QString *errorString) // allow that. setFileReadOnly(fileName, false); #endif - - try { - if (!std::filesystem::remove(std::filesystem::path{fileName.toStdWString()})) { - if (errorString) { - *errorString = QObject::tr("File is already deleted"); - } - qCWarning(lcFileSystem()) << "File is already deleted" << fileName; - return false; - } - qCInfo(lcFileSystem()) << "delete" << fileName; - } - catch (const std::filesystem::filesystem_error &e) - { - if (errorString) { - *errorString = QString::fromLatin1(e.what()); - } - qCWarning(lcFileSystem()) << e.what() << fileName; - return false; - } - catch (...) - { + QFile f(fileName); + if (!f.remove()) { if (errorString) { - *errorString = QObject::tr("Error deleting the file"); + *errorString = f.errorString(); } - qCWarning(lcFileSystem()) << "Error deleting the file" << fileName; + qCWarning(lcFileSystem()) << f.errorString() << fileName; return false; } - return true; } -- 2.30.2